﻿using In66.Net.Mongo.Extensions;

namespace In66.Net.Share.Registrar;
public abstract partial class AbstractWebApiDependencyRegistrar
{
    /// <summary>
    /// 注册MongoContext与仓储
    /// </summary>
    public virtual void AddMongoContextWithRepositries(Action<IServiceCollection>? action = null)
    {
        action?.Invoke(Services);

        var mongoConfig = MongoDbSection.Get<MongoConfig>();
        Services.AddInfraMongo<MongoContext>(options =>
        {
            options.ConnectionString = mongoConfig.ConnectionString;
            options.PluralizeCollectionNames = mongoConfig.PluralizeCollectionNames;
            options.CollectionNamingConvention = mongoConfig.CollectionNamingConvention;
        });
    }
}
